﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Gift.DAL;
using Gift.Model;

namespace WebSite.admin.admin
{
    public partial class roleAdd : BaseAdmin
    {
        readonly dalRole theRole = new dalRole();
        tbRole oRole;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["rid"] != null)
                {
                  oRole = theRole.GetModel(int.Parse(Request.QueryString["rid"]));
                    this.txtRemake.Text = oRole.Remark;
                    this.txtRoleName.Text = oRole.RoleName;
                }
            }
        }

        protected void btnSubmitForm1_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["rid"] != null)
            {
                oRole = theRole.GetModel(int.Parse(Request.QueryString["rid"]));
                oRole.Remark = this.txtRemake.Text.Trim();
                oRole.RoleName = this.txtRoleName.Text.Trim();
                theRole.Update(oRole);
                ExtAspNet.Alert.Show("修改成功！", "", "openNewTab('RoleManager','/admin/admin/roleManager.aspx','角色列表','RoleAdd')");
            }else
            {
                oRole = new tbRole();
                oRole.Remark = this.txtRemake.Text.Trim();
                oRole.RoleName = this.txtRoleName.Text.Trim();
                oRole.createTime = DateTime.Now;
                theRole.Add(oRole);

                ExtAspNet.Alert.Show("添加成功！", "", "openNewTab('RoleManager','/admin/admin/roleManager.aspx','角色列表','RoleAdd')");

            }


        }
    }
}